package com.example.apisimpledy.repository;

import com.example.apisimpledy.entity.dto.Comment;
import org.springframework.data.domain.Page;
import com.example.apisimpledy.entity.dto.MyUser;
import com.example.apisimpledy.entity.dto.Video;
import com.example.apisimpledy.entity.dto.VideoLike;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface VideoRepository extends JpaRepository<Video, Long> {
    Page<Video> findByMyUserId(Long userId, Pageable pageable);
    @Query("SELECT v FROM Video v WHERE v.id NOT IN (SELECT vv.video.id FROM VideoView vv WHERE vv.myUser.id = :userId) ORDER BY v.likes DESC")
    List<Video> findRecommendedVideosExcludingViewedByUser(@Param("userId") Long userId);

}
